﻿using System.Web.Script.Serialization;

namespace BlizzardApi.Services
{
    public interface IResponseParser
    {
        T Parse<T>(string response);
    }

    public class ResponseParser : IResponseParser
    {
        private readonly static JavaScriptSerializer Serializer = new JavaScriptSerializer{MaxJsonLength = int.MaxValue};

        public T Parse<T>(string response)
        {
            if (string.IsNullOrEmpty(response))
                return default(T);

            return Serializer.Deserialize<T>(response);
        }
    }
}
